﻿@model MvcSimplyCleverPart3.Models.UserAddressViewModel[]


<div class="addresses">
    @foreach (var userAddress in Model)
    {
        <div class="address">
            @Html.Partial(GetTemplate(userAddress.Address.CountryCode), userAddress.Address)
           </div>
        <div class="modified">
         <span class="label">@SimplyCleverResources.LastModified</span>  @Html.DisplayFor(m=> userAddress.LastModified)
        </div>
    }
</div>

@functions
{
    private string GetTemplate(string countryCode)
    {
        var metadataCountry = SimplyCleverMiddleTier.CountryProvider.GetCountries();
        return "~/Views/Contact/DisplayTemplates/Address" + metadataCountry.First(mc => mc.Code.Equals(countryCode)).AddressFormatInfo.FormatKey + ".cshtml";
    }
}
